<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 属性绑定事件处理函数 -->
    <!-- <button onclick="function(){fn()}">保存1</button> -->
    <!-- <button onclick="function(){fn();console.log('jack');}">保存2</button> -->
    <button id="btn1">保存1</button>
    <button id="btn2">保存2</button>
    <script>
      function fn() {
        console.log("hello");
      }
      const btn1 = document.getElementById("btn1");
      const btn2 = document.getElementById("btn2");
      btn1.onclick = function () {
        fn();
      };
      // btn1.onclick();
      btn2.onclick = function () {
        fn();
        console.log("jack");
      };
    </script>
  </body>
</html>
